<template>
  <!-- 辅导员统计页面 -->
  <div class="app-container">
    <searchForm
      :formOptions="formOptions"
      @onSearch="onSearch"
      @onReset="onReset"
      :formLabelWidth="formLabelWidth"
      v-show="showSearch"
    />
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table :data="roleList">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <el-table-column label="教工号" prop="tno" align="center" />
      <el-table-column label="姓名" prop="thrName" align="center" />
      <el-table-column
        label="性别"
        prop="sex"
        align="center"
      >
      <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex"></dict-tag>
        </template>
    </el-table-column>
    <el-table-column label="在岗状态" prop="postStatus" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.basic_post_status" :value="scope.row.postStatus" />
        </template>
      </el-table-column>
      <el-table-column label="院系名称" prop="deptName" align="center" />
      <!-- <el-table-column label="专业名称" prop="roleSort" align="center" /> -->
      <!-- <el-table-column label="学制" prop="roleSort" align="center" /> -->
      <!-- <el-table-column label="年级" prop="roleSort" align="center" />
      <el-table-column label="毕业状态" prop="roleSort" align="center" /> -->
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            >班级详情信息</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 任命辅导员弹框 -->
    <el-dialog :title="title" :visible.sync="open" width="60%" append-to-body>
      <!-- <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        :inline="true"
        v-show="showSearch"
      >
        <el-form-item label="教师工号" prop="roleName">
          <el-input
            v-model="queryParams.roleKey"
            placeholder="请输入教师工号"
            clearable
            style="width: 200px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="教师姓名" prop="roleKey">
          <el-input
            v-model="queryParams.roleKey"
            placeholder="请输入教师姓名"
            clearable
            style="width: 200px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form> -->
      <el-table :data="counsellorList.slice((counselorParams.pageNumber-1)*counselorParams.pageSize,counselorParams.pageNumber*counselorParams.pageSize)">
        <el-table-column label="年级" prop="gradeName" align="center" />
        <el-table-column label="院系" prop="deptNames" :show-overflow-tooltip="true" align="center" />
        <el-table-column label="专业" prop="specialtyName" align="center" />
        <el-table-column label="班号" prop="classCode" align="center" />
        <el-table-column label="班级名称" prop="className" align="center" />
        <el-table-column label="人数" prop="classSize" align="center" />
        <el-table-column label="岗位起始时间" prop="startTime" align="center" />
        <el-table-column label="岗位截至时间" prop="endTime" align="center" />
      </el-table>
      <el-pagination style="text-align: right;"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="counselorParams.pageNumber"
      :page-sizes="[10,20,30,50]"
      :page-size="10"
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="counsellorList.length">
    </el-pagination>
    </el-dialog>
  </div>
</template>

<script>
import {

  delRole,
  addRole,
  updateRole,
  dataScope,
  changeRoleStatus,
  deptTreeSelect,
} from "@/api/system/role";
import searchForm from "@/components/Search/searchForm.vue";
import { clrClassList,crlClass} from "@/api/counselor/division";

export default {
  name: "Role",
  dicts: [
    "sys_normal_disable",
    "sys_user_sex",
    'basic_post_status'
  ],
  components: { searchForm },

  data() {
    return {
      formLabelWidth: "60px",
      formOptions: [
        {
          label: "教工号",
          prop: "tno",
          element: "el-input",
          placeholder: "请输入教工号",
        },
        {
          label: "姓名",
          prop: "thrName",
          element: "el-input",
          placeholder: "请输入姓名",
        },
        // {
        //   label: "院系名称",
        //   prop: "MC",
        //   element: "el-input",
        //   placeholder: "请输入院系名称",
        // },
        // {
        //   label: "入学年份",
        //   type: "date",
        //   prop: "timeRange",
        //   element: "el-date-picker",
        // },
        // {
        //   label: "专业名称",
        //   prop: "MC",
        //   element: "el-input",
        //   placeholder: "请输入院系名称",
        // },
        
        // {
        //   label: "毕业状态",
        //   prop: "type",
        //   element: "el-select",
        //   options: [
        //     { label: "毕业", value: "1" },
        //     { label: "在校", value: "2" },
        //   ],
        //   placeholder: "请选择在岗状态",
        // },
        // {
        //   label: "性别",
        //   prop: "XB",
        //   element: "el-select",
        //   options: [
        //     { label: "男", value: "1" },
        //     { label: "女", value: "2" },
        //   ],
        //   placeholder: "请选择任职类型",
        // },
        // {
        //   label: "学制",
        //   prop: "XZ",
        //   element: "el-input",
        //   placeholder: "请输入学制",
        // },
      ],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      roleList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层（数据权限）
      menuExpand: false,
      menuNodeAll: false,
      deptExpand: true,
      deptNodeAll: false,
      // 日期范围
      dateRange: [],
      counsellorList:[],
      divisionInfor: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        isClr: 0,
      },
      counselorParams: {
        pageNumber: 1,
        pageSize: 10
      },
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
     // 获取搜索表单提交的数据
     onSearch(val) {
      // 查询条件和分页数据合并
      this.queryParams = Object.assign(this.queryParams, val);
      this.queryParams.pageNum = 1;
      this.getList();
    },
     // 重置
     onReset(data) {
      console.log(data);
      this.queryParams.pageNum = 1;
      this.queryParams = Object.assign(this.queryParams, data);
      this.getList();
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      clrClassList(this.queryParams).then(
        (response) => {
          this.roleList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
   
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.open = true;
      this.title = "辅导员分班详情";
      this.divisionInfor = row;
      console.log(row)
      crlClass(row.cId,1).then(response => {
        console.log(response,'分班查看')
        this.counsellorList = response.data.classList
   
      })
    },
     //pageSize改变时触发的事件
     handleSizeChange(val) {
      this.counselorParams.pageNumber = 1;
      this.counselorParams.pageSize = val;
    },
    //当前页码发生改变时触发的事件
    handleCurrentChange(val) {
      this.counselorParams.pageNumber = val;
    }
   
  },
};
</script>